package com.llmops.demo;

import com.llmops.core.listener.ChatModelLogListener;
import dev.langchain4j.model.input.structured.StructuredPrompt;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.output.structured.Description;
import dev.langchain4j.service.AiServices;

import java.util.List;

public class 分类1 {

    static class POJO_With_Descriptions_Extracting_AI_Service_Example {

        static class ClassificationResult {

            @Description("分类的结果")
            private String classification;

            @Override
            public String toString() {
                return classification;
            }
        }

        @StructuredPrompt("将用户输入:{{input}},分类为:{{classifications}}")
        static class CreateRecipePrompt {
            private String input;
            private List<String> classifications;
        }

        interface Classification {
            ClassificationResult classification(CreateRecipePrompt prompt);
        }

        public static void main(String[] args) {

            OpenAiChatModel chatModel = OpenAiChatModel.builder()
                    .baseUrl("https://api.deepseek.com/v1")
                    .apiKey("sk-0c3e6a9f9f7a4e63bb855290c544183c")
                    .modelName("deepseek-chat")
                    .listeners(List.of(new ChatModelLogListener()))
                    .build();

            Classification classification = AiServices.create(Classification.class, chatModel);

            CreateRecipePrompt prompt = new CreateRecipePrompt();
//            prompt.input = "这个手机的像素是多少";
            prompt.input = "我买的手机屏幕坏了";
            prompt.classifications = List.of("售前","售后");

            ClassificationResult anotherRecipe = classification.classification(prompt);
            System.out.println(anotherRecipe);
            // Recipe ...
        }
    }
}
